//
//  AloTruyenModal.m
//  AloTruyen
//
//  Created by vominhthong on 9/27/14.
//  Copyright (c) 2014 Khoai Nguyen Minh. All rights reserved.
//

#import "AloTruyenModal.h"
@implementation Author
-(instancetype)initAuthorWithDictionary:(NSDictionary *)params{
    if ([super init]) {
        self.nameAuthor = params[@"name"];
        self.idAuthor = params[@"id"];
    }
    return self;

}
@end

@implementation AloTruyenModal
-(instancetype)initHomeItemWithDictionary:(NSDictionary *)params{
    if (self = [super init]) {
        self.titleBook = params[@"title"];
        self.thumbNail = [NSURL URLWithString:params[@"image"]];
        self.specID = params[@"spec_id"];
    }
    return self;
}

-(instancetype)initWithDictionary:(NSDictionary *)params{
    if ([super init]) {
        self.titleBook = params[@"name"];
        self.downloadCount = params[@"download_count"];
        self.thumbNail = [NSURL URLWithString:params[@"image"]];
        self.idBook = params[@"id"];
        self.author = [[Author alloc]initAuthorWithDictionary:params[@"author"]];
        NSLog(@"OK");
    }
    return self;
}
-(instancetype)initHomeItemWithSpecIDFromLeftMenu:(NSDictionary *)params{
    if (self = [super init]) {
        self.specID = params[@"id"];
        self.thumbNail = [NSURL URLWithString:params[@"image"]];
        self.titleBook = params[@"title"];
        if (!self.titleBook) {
            self.titleBook = params[@"name"];
        }
    }
    return self;
}
@end
